package com.xiao.permission_system.security;

import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.IOException;

/**
 * @author beth
 * @data 2019-12-03 18:15
 */
public class LoginSuccessHandler implements org.springframework.security.web.authentication.AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
       httpServletResponse.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
       httpServletResponse.getWriter().write("[\"code\":\"200\",\"msg\":\"登陆成功\"]");
    }
}
